<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>订餐系统后台管理</title>
    <link href="/static/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="/static/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="/static/css/style.css" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="loginColumns">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="ibox-content">
                    <div class="m-t login-wrap">
                        <div class="form-group text-center">
                            <h2 class="font-bold">登录</h2>
                        </div>
                        <div class="form-group">
                            <input type="text" name="login_name" class="form-control" placeholder="请输入登录手机号">
                        </div>
                        <div class="form-group">
                            <input type="password" name="login_pwd" class="form-control" placeholder="请输入6-16位登录密码">
                        </div>
                        <button type="button" class="btn btn-primary block full-width m-b do-login">登录</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="/static/plugins/jquery-2.1.1.js"></script>
<script src="/static/bootstrap/bootstrap.min.js"></script>
<script src="/static/plugins/layer/layer.js"></script>
<script src="/static/js/common.js"></script>
<script>
	var user_login = {
		init:function(){
			this.eventBind()
		},
        isPhone:function(phones){
            var myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/;
            return myreg.test(phones)
        },
		eventBind:function(){
            $(".login-wrap .do-login").click(function(){
                var login_name = $(".login-wrap input[name=login_name]").val();
                var login_pwd = $(".login-wrap input[name=login_pwd]").val();

                if (login_name == "" || !user_login.isPhone(login_name)){
                    common_ops.alert("请输入正确的登录用户名！")
                    return ;
                }
                if (login_pwd == "" || login_pwd.length < 6 || login_pwd.length > 16){
                    common_ops.alert("请输入6-16位密码！")
                    return ;
                }

                $.ajax({
                    url:"/user/login",
                    type:"POST",
                    data:{"login_name":login_name,"login_pwd":login_pwd},
                    dataType:"json",
                     success:function(res){
                        if(res.code == 200){
                            window.location.href = "/"
                        }
                        if(res.code == -1){
                            common_ops.alert(res.msg)
                        }
                    }
                })

            });
		}
	}
    $(document).ready(function(){
        user_login.init();
    })

</script>
</html>





